package com.xiaoyu.lanling.feature.chat.model.message

import com.xiaoyu.base.data.UserInfoDataProvider
import com.xiaoyu.base.entity.ConversationEntity
import com.xiaoyu.base.model.User
import com.xiaoyu.im.datamodel.AppMessage
import com.xiaoyu.im.datamodel.MessageDisplayStatus.MessageDisplayStatusDef
import com.xiaoyu.im.provider.ConversationManager
import com.xiaoyu.lanling.media.image.UserImageLoadParam.Companion.newBuilder

abstract class ChatMessageReceiveSendBaseItem(message: AppMessage) : ChatMessageBaseItem(message) {

    @MessageDisplayStatusDef
    val messageDisplayStatus = message.toDisplayStatus()
    val user: User = UserInfoDataProvider.getInstance().fetchFromMemory(message.senderUid)
    val avatarParam = newBuilder().setUserAndDP(user, 40).build()
    val conversation: ConversationEntity? = ConversationManager.getInstance().fetchConversation(message.chatToken.chatId)
    val singleChat = ConversationManager.getInstance().isSingleChat(conversation)

    protected abstract val childrenViewType: Int

    override fun getViewType(): Int {
        return childrenViewType
    }
}